<?php
// $Id$

/**
 * Controller_Admin_Trunk_Group 控制器
 */
class Controller_Admin_Trunkgroup extends Controller_Abstract
{
	/**
	 *
	 * 删除路由
	 */
	function actiontrunkdel()
	{
		Syslog::logs('删除呼出路由:'.$this->_context->ids);
		$this->union_table = Getewaypolicy::meta();
		$this->delete(array('id'=>$this->_context->ids));
	}
	/**
	 *
	 * 路由组删除
	 */
	function actiongroupdel()
	{
		Syslog::logs('删除呼出路由组:'.$this->_context->ids);
		$this->union_table = Getewaygroup::meta();
		$this->delete(array('id'=>$this->_context->ids));
	}
	/**
	 *
	 * 呼出路由组查看
	 */
	function actionIndex()
	{
		$this->union_table = Getewaygroup::meta();
		$this->lists();
	}
	/**
	 *
	 * 呼出路由组添加
	 */
	function actiongroupadd()
	{
		$this->union_table = Getewaygroup::meta();
		$handle = new helper_autoinsert($this->union_table);
		$form = new Form_trunkgroup_groupadd(url('trunkgroup/groupadd'));

		$result = $handle->add($form, 'id', $_GET);
		if ($this->_context->isGET())
		{
			$this->_view['form'] = $result;
			$this->_viewname = '../form/add';
		}else {
			Syslog::logs('编辑呼出路由组:'.$_POST['gatewaygroupname']);
			return call_user_func_array(array($this,$handle->status),array($result));
		}
	}
	/**
	 *
	 * 呼出路由添加
	 */
	function actiontrunkadd()
	{
		$this->union_table = Getewaypolicy::meta();
		$handle = new helper_autoinsert($this->union_table);
		$form = new Form_trunkgroup_trunkadd(url('trunkgroup/trunkadd'));

		$result = $handle->add($form, 'id', $_GET);
		if ($this->_context->isGET())
		{
			$trunk_array = Gateway::_get_arrayinfo();
			$result->element('gatewayid')->items = $trunk_array;
			$this->_view['form'] = $result;
			$this->_viewname = '../form/add';
		}else {
			Syslog::logs('编辑呼出路由:'.$_POST['name']);
			return call_user_func_array(array($this,$handle->status),array($result));
		}
	}
	/**
	 *
	 * 呼出路由查看
	 */
	function actiontrunk()
	{
		$this->union_table = Getewaypolicy::meta();
		$gatewaygroupid = $this->_context->get('gatewaygroupid',NULL);
		$param = array();
		if (!is_null($gatewaygroupid))
		{
			$param = array('gatewaygroupid'=>$gatewaygroupid);
		}
		$this->orderkey = 'priority';
		$this->ordertype = 'asc';
		$this->lists($param);
	}

}


